package edu.hitsz.prop;

import edu.hitsz.aircraft.AbstractAircraft;
import edu.hitsz.application.Main;
import edu.hitsz.application.MusicThread;
import edu.hitsz.aircraft.shoot.DispersiveShoot;
import edu.hitsz.aircraft.shoot.StraightShoot;

/**
 * 子弹道具
 *
 * @author CsCN
 */
public class BulletProp extends AbstractProp {

    public BulletProp(int locationX, int locationY, int speedX, int speedY) {
        super(locationX, locationY, speedX, speedY);
    }

    @Override
    public int acquireProp(AbstractAircraft hero) {
        if (Main.musicFlag) {
            new MusicThread("bullet.wav").start();
        }
        Runnable r = () -> {
            hero.setShootStrategy(new DispersiveShoot());
            hero.setShootNum(hero.getShootNum() + 1);
            try {
                Thread.sleep(10 * 1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            hero.setShootNum(hero.getShootNum() - 1);
            if (hero.getShootNum() == 1){
                hero.setShootStrategy(new StraightShoot());
            }
        };
        new Thread(r).start();
        return 0;
    }
}